package com.object.oriented.exam.system5.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.object.oriented.exam.system5.entity.Score;
import com.object.oriented.exam.system5.service.ScoreService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author xdf
 * @date 2023-06-14
 */
@RequestMapping("/score")
@RestController
public class ScoreController {

    @Resource
    ScoreService scoreService;

    @GetMapping("/{studentId}/{examId}")
    public Score getScore(@PathVariable Long studentId,@PathVariable Long examId){
        return scoreService.getScore(studentId,examId);
    }

//    @GetMapping("/{studentId}/{examId}/{current}/{size}")
//    public Page<Score> getScoreInPage(@PathVariable Long studentId,@PathVariable Long examId,@PathVariable Long current, @PathVariable Long size){
//        return scoreService.getScores(studentId,examId,current,size);
//    }

    /**
     * 分页获取某次考试所有学生
     * @param examId
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/{examId}/{current}/{size}")
    public Page<Score> getScoreInPage(@PathVariable Long examId,@PathVariable Long current, @PathVariable Long size){
        return scoreService.getScoresInExam(examId,current,size);
    }

    /**
     * 计算某次考试某个学生的总分
     * @param studentId
     * @param examId
     * @return
     */
    @GetMapping("/compute/{studentId}/{examId}")
    public Integer compute(@PathVariable Long studentId,@PathVariable Long examId){
        return scoreService.compute(studentId,examId);
    }
}
